package jia.core.calculations;

import jia.core.characters.Race;
import jia.game.GenericFlags;
import org.apache.log4j.Logger;

/**
 * Determines whether a characters selected race has any effect on their
 * attribute scores
 *
 * @author Erik Stell
 * @version 1.0
 * @since 01/19/06
 */
public class RacialModifier{
    private static final Logger log = Logger.getLogger(RacialModifier.class);
    public static int calculate(String attrType, Race race){
        int retVal = 0;
        try {
            if("Strength".equals(attrType) && race.getStrMod() != 0) {
                retVal = race.getStrMod();
            }
            if("Dexterity".equals(attrType) && race.getDexMod() != 0) {
                retVal = race.getDexMod();
            }
            if("Constitution".equals(attrType) && race.getConMod() != 0) {
                retVal = race.getConMod();
            }
            if("Intelligence".equals(attrType) && race.getIntMod() != 0) {
                retVal = race.getIntMod();
            }
            if("Wisdom".equals(attrType) && race.getWisMod() != 0) {
                retVal = race.getWisMod();
            }
            if("Charisma".equals(attrType) && race.getChaMod() != 0) {
                retVal = race.getChaMod();
            }
        } catch(Exception e) {
            if (GenericFlags.errorMessages){
                log.error(e.getMessage());
            }
        }
        return retVal;
    }
}
